SET NOCOUNT ON;
declare @release smallint = 8;
declare @version smallint = 0;
declare @script_name varchar(256);
declare @script_type varchar(20)='CensusData';
set @script_name=@script_type+'_V'+convert(varchar(5),@version)+'R'+right('00000'+convert(varchar(5),@release),5)+'.sql'

if exists (select 1 from dbo.database_version_information where script_name=@script_name and undone=0)
	print 'script '+@script_name+' already executed, please undo then re-execute.';
else
begin try
begin tran
/*--Begin Code Here --*/

insert into dbo.ACSSF_Load_Control 
values
('Summary_File_0002','2013e1',0,7801,NULL,NULL)
,('Summary_File_0002','2012e1',0,7750,NULL,NULL)

if exists (select * from sys.tables where object_id=object_id('ACSSF.Summary_File_0002'))
	drop table ACSSF.Summary_File_0002;

create table ACSSF.Summary_File_0002 (
FILEID char(6) not null				/*File Identification 6 Characters*/
,FILETYPE char(6) not null			/*File Type 6 Characters*/
,STUSAB char(2) not null			/*State/U.S.-Abbreviation (USPS) 2 Characters*/ 
,CHARITER char(3) not null			/*Character Iteration 3 Characters*/ 
,SEQUENCE char(4) not null			/*Sequence Number 4 Characters */
,LOGRECNO char(7) not null			/*Logical Record Number 7 Characters*/ 
,Total_Population int null
,Total_Population_Male int null
,Total_Population_Male_Under_5_years int null
,Total_Population_Male_5_to_9_Years int null
,Total_Population_Male_10_to_14_Years int null
,Total_Population_Male_15_to_17_Years int null
,Total_Population_Male_18_and_19_Years int null
,Total_Population_Male_20_Years int null
,Total_Population_Male_21_Years int null
,Total_Population_Male_22_to_24_Years int null
,Total_Population_Male_25_to_29_Years int null
,Total_Population_Male_30_to_34_Years int null
,Total_Population_Male_35_to_39_Years int null
,Total_Population_Male_40_to_44_Years int null
,Total_Population_Male_45_to_49_Years int null
,Total_Population_Male_50_to_54_Years int null
,Total_Population_Male_55_to_59_Years int null
,Total_Population_Male_60_and_61_Years int null
,Total_Population_Male_62_to_64_Years int null
,Total_Population_Male_65_and_66_Years int null
,Total_Population_Male_67_to_69_Years int null
,Total_Population_Male_70_to_74_Years int null
,Total_Population_Male_75_to_79_Years int null
,Total_Population_Male_80_to_84_Years int null
,Total_Population_Male_85_Years_and_over int null
,Total_Population_Female int null
,Total_Population_Female_Under_5_years int null
,Total_Population_Female_5_to_9_Years int null
,Total_Population_Female_10_to_14_Years int null
,Total_Population_Female_15_to_17_Years int null
,Total_Population_Female_18_and_19_Years int null
,Total_Population_Female_20_Years int null
,Total_Population_Female_21_Years int null
,Total_Population_Female_22_to_24_Years int null
,Total_Population_Female_25_to_29_Years int null
,Total_Population_Female_30_to_34_Years int null
,Total_Population_Female_35_to_39_Years int null
,Total_Population_Female_40_to_44_Years int null
,Total_Population_Female_45_to_49_Years int null
,Total_Population_Female_50_to_54_Years int null
,Total_Population_Female_55_to_59_Years int null
,Total_Population_Female_60_and_61_Years int null
,Total_Population_Female_62_to_64_Years int null
,Total_Population_Female_65_and_66_Years int null
,Total_Population_Female_67_to_69_Years int null
,Total_Population_Female_70_to_74_Years int null
,Total_Population_Female_75_to_79_Years int null
,Total_Population_Female_80_to_84_Years int null
,Total_Population_Female_85_Years_and_over int null
,Total_Population_White int null
,Total_Population_Male_White int null
,Total_Population_Male_White_Under_5_Years int null
,Total_Population_Male_White_5_to_9_Years int null
,Total_Population_Male_White_10_to_14_Years int null
,Total_Population_Male_White_15_to_17_Years int null
,Total_Population_Male_White_18_and_19_Years int null
,Total_Population_Male_White_20_to_24_Years int null
,Total_Population_Male_White_25_to_29_Years int null
,Total_Population_Male_White_30_to_34_Years int null
,Total_Population_Male_White_35_to_44_Years int null
,Total_Population_Male_White_45_to_54_Years int null
,Total_Population_Male_White_55_to_64_Years int null
,Total_Population_Male_White_65_to_74_Years int null
,Total_Population_Male_White_75_to_84_Years int null
,Total_Population_Male_White_85_Years_and_over int null
,Total_Population_Female_White int null
,Total_Population_Female_White_Under_5_Years int null
,Total_Population_Female_White_5_to_9_Years int null
,Total_Population_Female_White_10_to_14_Years int null
,Total_Population_Female_White_15_to_17_Years int null
,Total_Population_Female_White_18_and_19_Years int null
,Total_Population_Female_White_20_to_24_Years int null
,Total_Population_Female_White_25_to_29_Years int null
,Total_Population_Female_White_30_to_34_Years int null
,Total_Population_Female_White_35_to_44_Years int null
,Total_Population_Female_White_45_to_54_Years int null
,Total_Population_Female_White_55_to_64_Years int null
,Total_Population_Female_White_65_to_74_Years int null
,Total_Population_Female_White_75_to_84_Years int null
,Total_Population_Female_White_85_Years_and_over int null
,Total_Population_Black_or_African_American int null
,Total_Population_Male_Black_or_African_American int null
,Total_Population_Male_Black_or_African_American_Under_5_Years int null
,Total_Population_Male_Black_or_African_American_5_to_9_Years int null
,Total_Population_Male_Black_or_African_American_10_to_14_Years int null
,Total_Population_Male_Black_or_African_American_15_to_17_Years int null
,Total_Population_Male_Black_or_African_American_18_and_19_Years int null
,Total_Population_Male_Black_or_African_American_20_to_24_Years int null
,Total_Population_Male_Black_or_African_American_25_to_29_Years int null
,Total_Population_Male_Black_or_African_American_30_to_34_Years int null
,Total_Population_Male_Black_or_African_American_35_to_44_Years int null
,Total_Population_Male_Black_or_African_American_45_to_54_Years int null
,Total_Population_Male_Black_or_African_American_55_to_64_Years int null
,Total_Population_Male_Black_or_African_American_65_to_74_Years int null
,Total_Population_Male_Black_or_African_American_75_to_84_Years int null
,Total_Population_Male_Black_or_African_American_85_Years_and_over int null
,Total_Population_Female_Black_or_African_American int null
,Total_Population_Female_Black_or_African_American_Under_5_Years int null
,Total_Population_Female_Black_or_African_American_5_to_9_Years int null
,Total_Population_Female_Black_or_African_American_10_to_14_Years int null
,Total_Population_Female_Black_or_African_American_15_to_17_Years int null
,Total_Population_Female_Black_or_African_American_18_and_19_Years int null
,Total_Population_Female_Black_or_African_American_20_to_24_Years int null
,Total_Population_Female_Black_or_African_American_25_to_29_Years int null
,Total_Population_Female_Black_or_African_American_30_to_34_Years int null
,Total_Population_Female_Black_or_African_American_35_to_44_Years int null
,Total_Population_Female_Black_or_African_American_45_to_54_Years int null
,Total_Population_Female_Black_or_African_American_55_to_64_Years int null
,Total_Population_Female_Black_or_African_American_65_to_74_Years int null
,Total_Population_Female_Black_or_African_American_75_to_84_Years int null
,Total_Population_Female_Black_or_African_American_85_Years_and_over int null
,Total_Population_American_Indian_and_Alaska int null
,Total_Population_Male_American_Indian_and_Alaska int null
,Total_Population_Male_American_Indian_and_Alaska_Native_Under_5_Years int null
,Total_Population_Male_American_Indian_and_Alaska_Native_5_to_9_Years int null
,Total_Population_Male_American_Indian_and_Alaska_Native_10_to_14_Years int null
,Total_Population_Male_American_Indian_and_Alaska_Native_15_to_17_Years int null
,Total_Population_Male_American_Indian_and_Alaska_Native_18_and_19_Years int null
,Total_Population_Male_American_Indian_and_Alaska_Native_20_to_24_Years int null
,Total_Population_Male_American_Indian_and_Alaska_Native_25_to_29_Years int null
,Total_Population_Male_American_Indian_and_Alaska_Native_30_to_34_Years int null
,Total_Population_Male_American_Indian_and_Alaska_Native_35_to_44_Years int null
,Total_Population_Male_American_Indian_and_Alaska_Native_45_to_54_Years int null
,Total_Population_Male_American_Indian_and_Alaska_Native_55_to_64_Years int null
,Total_Population_Male_American_Indian_and_Alaska_Native_65_to_74_Years int null
,Total_Population_Male_American_Indian_and_Alaska_Native_75_to_84_Years int null
,Total_Population_Male_American_Indian_and_Alaska_Native_85_Years_and_over int null
,Total_Population_Female_American_Indian_and_Alaska int null
,Total_Population_Female_American_Indian_and_Alaska_Native_Under_5_Years int null
,Total_Population_Female_American_Indian_and_Alaska_Native_5_to_9_Years int null
,Total_Population_Female_American_Indian_and_Alaska_Native_10_to_14_Years int null
,Total_Population_Female_American_Indian_and_Alaska_Native_15_to_17_Years int null
,Total_Population_Female_American_Indian_and_Alaska_Native_18_and_19_Years int null
,Total_Population_Female_American_Indian_and_Alaska_Native_20_to_24_Years int null
,Total_Population_Female_American_Indian_and_Alaska_Native_25_to_29_Years int null
,Total_Population_Female_American_Indian_and_Alaska_Native_30_to_34_Years int null
,Total_Population_Female_American_Indian_and_Alaska_Native_35_to_44_Years int null
,Total_Population_Female_American_Indian_and_Alaska_Native_45_to_54_Years int null
,Total_Population_Female_American_Indian_and_Alaska_Native_55_to_64_Years int null
,Total_Population_Female_American_Indian_and_Alaska_Native_65_to_74_Years int null
,Total_Population_Female_American_Indian_and_Alaska_Native_75_to_84_Years int null
,Total_Population_Female_American_Indian_and_Alaska_Native_85_Years_and_over int null
,Total_Population_Asian int null
,Total_Population_Male_Asian int null
,Total_Population_Male_Asian_Under_5_Years int null
,Total_Population_Male_Asian_5_to_9_Years int null
,Total_Population_Male_Asian_10_to_14_Years int null
,Total_Population_Male_Asian_15_to_17_Years int null
,Total_Population_Male_Asian_18_and_19_Years int null
,Total_Population_Male_Asian_20_to_24_Years int null
,Total_Population_Male_Asian_25_to_29_Years int null
,Total_Population_Male_Asian_30_to_34_Years int null
,Total_Population_Male_Asian_35_to_44_Years int null
,Total_Population_Male_Asian_45_to_54_Years int null
,Total_Population_Male_Asian_55_to_64_Years int null
,Total_Population_Male_Asian_65_to_74_Years int null
,Total_Population_Male_Asian_75_to_84_Years int null
,Total_Population_Male_Asian_85_Years_and_over int null
,Total_Population_Female_Asian int null
,Total_Population_Female_Asian_Under_5_Years int null
,Total_Population_Female_Asian_5_to_9_Years int null
,Total_Population_Female_Asian_10_to_14_Years int null
,Total_Population_Female_Asian_15_to_17_Years int null
,Total_Population_Female_Asian_18_and_19_Years int null
,Total_Population_Female_Asian_20_to_24_Years int null
,Total_Population_Female_Asian_25_to_29_Years int null
,Total_Population_Female_Asian_30_to_34_Years int null
,Total_Population_Female_Asian_35_to_44_Years int null
,Total_Population_Female_Asian_45_to_54_Years int null
,Total_Population_Female_Asian_55_to_64_Years int null
,Total_Population_Female_Asian_65_to_74_Years int null
,Total_Population_Female_Asian_75_to_84_Years int null
,Total_Population_Female_Asian_85_Years_and_over int null
,Total_Population_Native_Hawaiian_and_Other_Pacific_Islander int null
,Total_Population_Male_Native_Hawaiian_and_Other_Pacific_Islander int null
,Total_Population_Male_Native_Hawaiian_and_Other_Pacific_Islander_Under_5_Years int null
,Total_Population_Male_Native_Hawaiian_and_Other_Pacific_Islander_5_to_9_Years int null
,Total_Population_Male_Native_Hawaiian_and_Other_Pacific_Islander_10_to_14_Years int null
,Total_Population_Male_Native_Hawaiian_and_Other_Pacific_Islander_15_to_17_Years int null
,Total_Population_Male_Native_Hawaiian_and_Other_Pacific_Islander_18_and_19_Years int null
,Total_Population_Male_Native_Hawaiian_and_Other_Pacific_Islander_20_to_24_Years int null
,Total_Population_Male_Native_Hawaiian_and_Other_Pacific_Islander_25_to_29_Years int null
,Total_Population_Male_Native_Hawaiian_and_Other_Pacific_Islander_30_to_34_Years int null
,Total_Population_Male_Native_Hawaiian_and_Other_Pacific_Islander_35_to_44_Years int null
,Total_Population_Male_Native_Hawaiian_and_Other_Pacific_Islander_45_to_54_Years int null
,Total_Population_Male_Native_Hawaiian_and_Other_Pacific_Islander_55_to_64_Years int null
,Total_Population_Male_Native_Hawaiian_and_Other_Pacific_Islander_65_to_74_Years int null
,Total_Population_Male_Native_Hawaiian_and_Other_Pacific_Islander_75_to_84_Years int null
,Total_Population_Male_Native_Hawaiian_and_Other_Pacific_Islander_85_Years_and_over int null
,Total_Population_Female_Native_Hawaiian_and_Other_Pacific_Islander int null
,Total_Population_Female_Native_Hawaiian_and_Other_Pacific_Islander_Under_5_Years int null
,Total_Population_Female_Native_Hawaiian_and_Other_Pacific_Islander_5_to_9_Years int null
,Total_Population_Female_Native_Hawaiian_and_Other_Pacific_Islander_10_to_14_Years int null
,Total_Population_Female_Native_Hawaiian_and_Other_Pacific_Islander_15_to_17_Years int null
,Total_Population_Female_Native_Hawaiian_and_Other_Pacific_Islander_18_and_19_Years int null
,Total_Population_Female_Native_Hawaiian_and_Other_Pacific_Islander_20_to_24_Years int null
,Total_Population_Female_Native_Hawaiian_and_Other_Pacific_Islander_25_to_29_Years int null
,Total_Population_Female_Native_Hawaiian_and_Other_Pacific_Islander_30_to_34_Years int null
,Total_Population_Female_Native_Hawaiian_and_Other_Pacific_Islander_35_to_44_Years int null
,Total_Population_Female_Native_Hawaiian_and_Other_Pacific_Islander_45_to_54_Years int null
,Total_Population_Female_Native_Hawaiian_and_Other_Pacific_Islander_55_to_64_Years int null
,Total_Population_Female_Native_Hawaiian_and_Other_Pacific_Islander_65_to_74_Years int null
,Total_Population_Female_Native_Hawaiian_and_Other_Pacific_Islander_75_to_84_Years int null
,Total_Population_Female_Native_Hawaiian_and_Other_Pacific_Islander_85_Years_and_over int null
,Total_Population_Some_Other_Race int null
,Total_Population_Male_Some_Other_Race int null
,Total_Population_Male_Some_Other_Race_Under_5_Years int null
,Total_Population_Male_Some_Other_Race_5_to_9_Years int null
,Total_Population_Male_Some_Other_Race_10_to_14_Years int null
,Total_Population_Male_Some_Other_Race_15_to_17_Years int null
,Total_Population_Male_Some_Other_Race_18_and_19_Years int null
,Total_Population_Male_Some_Other_Race_20_to_24_Years int null
,Total_Population_Male_Some_Other_Race_25_to_29_Years int null
,Total_Population_Male_Some_Other_Race_30_to_34_Years int null
,Total_Population_Male_Some_Other_Race_35_to_44_Years int null
,Total_Population_Male_Some_Other_Race_45_to_54_Years int null
,Total_Population_Male_Some_Other_Race_55_to_64_Years int null
,Total_Population_Male_Some_Other_Race_65_to_74_Years int null
,Total_Population_Male_Some_Other_Race_75_to_84_Years int null
,Total_Population_Male_Some_Other_Race_85_Years_and_over int null
,Total_Population_Female_Some_Other_Race int null
,Total_Population_Female_Some_Other_Race_Under_5_Years int null
,Total_Population_Female_Some_Other_Race_5_to_9_Years int null
,Total_Population_Female_Some_Other_Race_10_to_14_Years int null
,Total_Population_Female_Some_Other_Race_15_to_17_Years int null
,Total_Population_Female_Some_Other_Race_18_and_19_Years int null
,Total_Population_Female_Some_Other_Race_20_to_24_Years int null
,Total_Population_Female_Some_Other_Race_25_to_29_Years int null
,Total_Population_Female_Some_Other_Race_30_to_34_Years int null
,Total_Population_Female_Some_Other_Race_35_to_44_Years int null
,Total_Population_Female_Some_Other_Race_45_to_54_Years int null
,Total_Population_Female_Some_Other_Race_55_to_64_Years int null
,Total_Population_Female_Some_Other_Race_65_to_74_Years int null
,Total_Population_Female_Some_Other_Race_75_to_84_Years int null
,Total_Population_Female_Some_Other_Race_85_Years_and_over int null
,Constraint ACSSF__Summary_File_0002_PK Primary Key (
FILEID
,FILETYPE
,STUSAB
,CHARITER
,SEQUENCE
,LOGRECNO
)
);



/*--End Code Here --*/
if exists (select 1 from dbo.database_version_information where script_name=@script_name and undone=1)
	update dbo.database_version_information 
	set undone=0
	,date_released=getdate()
	where
	script_name=@script_name;
else
	insert into dbo.database_version_information 
	values(@script_name,@script_type,@version,@release,GETDATE(),0);
	
print 'script '+@script_name+' succeeded!'
commit tran
end try
begin catch 
	declare @error_message varchar(2000);
	set @error_message='SCRIPT:'+@script_name+' FAILED! ROLLBACK!  ERROR_MESSAGE:'
	+coalesce(error_message(),'')+' ERROR_NUMBER:'+coalesce(convert(varchar(10),error_number()),'');
	ROLLBACK
	raiserror(@error_message,16,1)
end catch
